package rmold

import (
	"huling/app/clien/article"
	"huling/app/clien/cardtpl"
	"huling/app/clien/home"
	"huling/app/clien/product"
	"huling/app/clien/system/account"
	"huling/app/clien/system/dept"
	"huling/app/clien/system/menu"
	"huling/app/clien/system/role"
	"huling/app/clien/user"
	"huling/app/clien/userlist"
	"huling/app/common"

	"github.com/gin-gonic/gin"
)

/**C端API*/
func ApiClient(R *gin.Engine) {
	//项目根模块
	clienPath := R.Group("/clien")
	{
		//模块公共的接口
		commonrPath := clienPath.Group("/common")
		{
			//文件管理
			attachmentRouter := commonrPath.Group("/attachment")
			{
				attachmentRouter.POST("/addCate", common.CateAdd)
				attachmentRouter.POST("/upfile", common.Upfile)
				attachmentRouter.DELETE("/delCate", common.DelCate)
				attachmentRouter.GET("/getList", common.GetCatelist)
				attachmentRouter.GET("/getImgList", common.GetImgList)
				attachmentRouter.DELETE("/delfile", common.Delfile)
			}
			//消息管理
			messageRouter := commonrPath.Group("/message")
			{
				messageRouter.GET("/getList", common.GetMessagelist)
				messageRouter.POST("/setRead", common.SetRead)
			}
		}
		//用户模块
		userPath := clienPath.Group("/user")
		{
			userPath.POST("/add", user.AddParam)
			userPath.GET("/userinfo", user.GetInfo)
			userPath.POST("/login", user.Lonin)
			userPath.GET("/refreshtoken", user.Refreshtoken)
			userPath.GET("/logout", user.Logout)
			userPath.POST("/updata", user.Updata)
			userPath.GET("/list", user.QueryParam)
			userPath.DELETE("/del", user.DelParam)
			userPath.POST("/changePwd", user.ChangePwd)
			//用户数据
			userPath.GET("/getUserData", user.GetUserData)
			userPath.POST("/upUserInfo", user.UpUserInfo)
			userPath.POST("/upAvatar", user.UpAvatar)
		}
		//权限模块
		authPath := clienPath.Group("/auth")
		{
			//路由菜单
			auth := authPath.Group("/rule")
			{
				auth.GET("/getMenuList", user.GetMenuList)
				auth.GET("/getPermCode", user.GetPermCode)
			}
		}
		//首页
		homePath := clienPath.Group("/home")
		{
			//路由菜单
			modelsPath := homePath.Group("/models")
			{
				modelsPath.GET("/getModels", home.GetModels)
			}
			//首页模板
			micwebtplPath := homePath.Group("/micwebtpl")
			{
				micwebtplPath.GET("/getTplGroup", home.GetTplGroup)
				micwebtplPath.GET("/getTpl", home.GetTpl)
			}
		}
		//1.系统设置
		systemPath := clienPath.Group("/system")
		{
			//系统菜单
			menuPath := systemPath.Group("/menu")
			{
				menuPath.GET("/getlist", menu.Getlist)
				menuPath.GET("/getParentList", menu.GetParentList)
				menuPath.POST("/saveMenu", menu.Add)
				menuPath.POST("/upMenuLock", menu.UpMenuLock)
				menuPath.DELETE("/delMenu", menu.Del)
			}
			//部门
			deptPath := systemPath.Group("/dept")
			{
				deptPath.GET("/getDeptList", dept.Getlist)
				deptPath.GET("/getParentList", dept.GetParentList)
				deptPath.POST("/save", dept.Add)
				deptPath.POST("/upLock", dept.UpLock)
				deptPath.DELETE("/del", dept.Del)
			}
			//角色
			rolePath := systemPath.Group("/role")
			{
				rolePath.GET("/getList", role.Getlist)
				rolePath.GET("/getParentList", role.GetParentList)
				rolePath.POST("/save", role.Add)
				rolePath.POST("/upLock", role.UpLock)
				rolePath.DELETE("/del", role.Del)
				rolePath.GET("/getMenuList", menu.GetMenuList)
			}
			//账号
			accountPath := systemPath.Group("/account")
			{
				accountPath.GET("/getList", account.Getlist)
				accountPath.GET("/getParentList", account.GetParentList)
				accountPath.GET("/getAllRoleList", role.GetAllList)
				accountPath.GET("/getRoleList", role.GetRoleList)
				accountPath.GET("/getLoginLogList", account.GetLoginLogList)
				accountPath.GET("/getAccount", account.GetAccount)
				accountPath.POST("/isAccountExist", account.IsAccountExist)
				accountPath.POST("/save", account.Add)
				accountPath.POST("/upLock", account.UpLock)
				accountPath.POST("/upAvatar", account.UpAvatar)
				accountPath.POST("/changePwd", account.ChangePwd)
				accountPath.DELETE("/del", account.Del)
			}
		}
		//1.产品
		productPath := clienPath.Group("/product")
		{
			productPath.GET("/getList", product.GetList)
			productPath.POST("/saveProduct", product.SaveProduct)
			productPath.POST("/upLock", product.UpLock)
			productPath.DELETE("/delProduct", product.DelProduct)
		}
		//2.文章
		articlePath := clienPath.Group("/article")
		{
			articlePath.GET("/getList", article.GetList)
			articlePath.POST("/saveProduct", article.SaveProduct)
			articlePath.POST("/upLock", article.UpLock)
			articlePath.DELETE("/delProduct", article.DelProduct)
		}
		//3.样式
		cardtplPath := clienPath.Group("/cardtpl")
		{
			cardtplPath.GET("/getList", cardtpl.GetList)
			cardtplPath.POST("/saveCardtpl", cardtpl.SaveCardtpl)
			cardtplPath.POST("/upLock", cardtpl.UpLock)
			cardtplPath.POST("/upSelect", cardtpl.UpSelect)
			cardtplPath.DELETE("/delCardtpl", cardtpl.DelCardtpl)
		}
		//4.用户
		userlistPath := clienPath.Group("/userlist")
		{
			userlistPath.GET("/getList", userlist.GetList)
			userlistPath.POST("/saveUser", userlist.SaveUser)
			userlistPath.POST("/upLock", userlist.UpLock)
		}

	}

}
